home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pasmouse.zip / MOUSE.PAS < prev    next >
Pascal/Delphi Source File  |  1991-05-02  |  27KB  |  870 lines

  1. {                               Msg #:  590                       PASCAL Subboard
  2.  From:  RON PRITCHETT             Sent: 04-30-91 20:58
  3.    Re:  MOUSE UNIT
  4.  * Origin: Ronnue's Realm - Columbia, SC (803)781-2440
  5.  
  6. }
  7.  
  8. UNIT Mouse;
  9. { Mouse unit for Turbo Pascal.
  10.   The comments in this unit were basically copied directly
  11.   from the Advanced MS Dos Programing book, the section on
  12.   the Microsoft Mouse Driver, which was the source of all
  13.   the mouse interrupt functions and their parameters.
  14. }
  15.  
  16.  
  17. INTERFACE
  18.  
  19. USES
  20.   Dos;
  21.  
  22. CONST
  23.   LeftButton = 1;
  24.   RightButton = 2;
  25.   CenterButton = 4;
  26.   AnyButton = 7;
  27.  
  28. PROCEDURE InitMouse(VAR Buttons : word; VAR Err : boolean);
  29. { Initializes the mouse driver.
  30.   Call:    nothing
  31.   Returns: Buttons = number of mouse buttons
  32.     Err     = false if mouse support is available, true otherwise
  33.    Note:    * After a call to this function the driver is initialized to
  34.               the following state:
  35.       - Mouse pointer at screen center and hidden.
  36.       - Display page is set to zero.
  37.       - Mouse pointer shape set to default arrow shape in graphics modes,
  38.         or reverse block in text modes.
  39.       - User mouse event handlers are disabled.
  40.       - Light pen emulation enabled.
  41.       - Mouse sensitivity set to default vales (see SetMouseSense)
  42.       - Pointer limits set to entire screen.
  43. }
  44.  
  45. PROCEDURE ShowPointer;
  46. { Displays the mouse pointer, and cancels any pointer exclusion area.
  47.   Call:    nothing
  48.   Returns: nothing
  49.   Note:    * A counter is maintained which is decremented by HidePointer
  50.              and is incremented (if nonzero) by this function.  The mouse
  51.              pointer is displayed any time the counter is zero.  The
  52.              counter is set to -1 when the mouse driver is reset.
  53. }
  54.  
  55. PROCEDURE HidePointer;
  56. { Removes the mouse pointer from the screen, but continues to track the
  57.   position of the mouse.
  58.   Call:    nothing
  59.   Returns: nothing
  60.   Note:    * see ShowPointer
  61. }
  62.  
  63. FUNCTION ButtonPressed(Mask : word) : boolean;
  64. { Returns a true value if the specified button(s) is pressed.
  65.   Call:    Mask = bit mask of desired button(s)
  66.     bit(s)  Significance(if set)
  67.     0       left button
  68.     1       right button
  69.     2       center button
  70.     3-15    reserved(0)
  71.   Returns: True is button is pressed, false otherwise.
  72.   Note:    * The constants LeftButton, RightButton, CenterButton, and
  73.              AnyButton can be used for the bit masking.  They equal 1, 2,
  74.              4, and 7 respectivly.
  75. }
  76.  
  77. PROCEDURE GetMousePosition(VAR Buttons, Horiz, Vert : word);
  78. { Returns the current mouse button status and pointer position.
  79.   Call:    nothing
  80.   Returns: Buttons = mouse button status
  81.     Horiz   = horizontal (X) coordinate
  82.     Vert    = vertical (Y) coordinate
  83.    Note:    * Coordinates are in pixels regardless of the current
  84.               display mode.
  85.       Position (0,0) is the upper left corner of the screen.
  86. }
  87.  
  88. FUNCTION MouseIn(x1,y1,x2,y2: word):boolean;
  89. { Returns true if mouse is within rectangle with upper-left
  90.   corner (x1,y1) and lower-right corner (x2,y2).
  91. }
  92.  
  93. PROCEDURE SetPointerPosition(Horiz, Vert : word);
  94. { Set the position of the pointer.  The pointer is displayed in the new
  95.   position unless it has been hidden using HidePointer or it is an
  96.   exclusion area defined by SetPointerExcl.
  97.   Call:    Horiz = horizontal (X) coordinate
  98.            Vert  = vertical (Y) coordinate
  99.   Returns: nothing
  100.   Notes:   * Coordinates are in pixels regardless of the current
  101.              display mode.
  102.       Position (0,0) is the upper left corner of the screen.
  103.     * The position is adjusted if necessary to lie within the pointer
  104.       limits set by SetLimits.
  105. }
  106.  
  107. PROCEDURE GetPressInfo(Button : word;
  108.          VAR Stat, Count, Horiz, Vert : word);
  109. { Returns the current status of all mouse buttons, and the number of
  110.   presses and position of the last press for a specifed mouse button
  111.   since the last call to this procedure for that button.  The press
  112.   counter for the button is reset to zero.
  113.   Call:    Button = button identifier
  114.       0 = left button
  115.       1 = right button
  116.       2 = center button
  117.   Returns: Stat   = button status
  118.       bit(s)  Significance(if set)
  119.       0       left button is down
  120.       1       right button is down
  121.       2       center button is down
  122.       3-15    reserved(0)
  123.     Count  = button press counter
  124.     Horiz  = horizontal (X) coordinate of last button press
  125.     Vert   = vertical (Y) coordinate of last button press
  126. }
  127.  
  128. PROCEDURE GetReleaseInfo(Button : word;
  129.     VAR Stat, Count, Horiz, Vert : word);
  130. { Returns the current status of all mouse buttons, and the number of
  131.   releases and position of the last release for a specifed mouse
  132.   button since the last call to this procedure for that button.  The
  133.   release counter for the button is reset to zero.
  134.   Call:    Button = button identifier
  135.       0 = left button
  136.       1 = right button
  137.       2 = center button
  138.   Returns: Stat   = button status
  139.       bit(s)  Significance(if set)
  140.       0       left button is down
  141.       1       right button is down
  142.       2       center button is down
  143.       3-15    reserved(0)
  144.     Count  = button release counter
  145.     Horiz  = horizontal (X) coordinate of last button release
  146.     Vert   = vertical (Y) coordinate of last button release
  147. }
  148.  
  149. PROCEDURE SetLimits(HorMin, HorMax, VerMin, VerMax : word);
  150. { Limits the mouse pointer to stay within a certain area.
  151.   Call:    HorMin = Minimum horizontal (X) coordinate
  152.     HorMax = Maximum horizontal (X) coordinate
  153.     VerMin = Minimum vertical (Y) coordinate
  154.     VerMax = Maximum vertical (Y) coordinate
  155.   Returns: nothing
  156.   Note:    * If both HorMin and HorMax are zero then then the previous
  157.              horizontal limits remain unchanged; the same is true for
  158.              VerMin and VerMax.
  159. }
  160.  
  161. PROCEDURE SetPointerShape(Horiz, Vert : word; Buffer : pointer);
  162. { Defines the shape, color, and hot spot of the pointer in graphics
  163.   modes.
  164.   Call:    Horiz  = hot spot offset from the left
  165.            Vert   = hot spot offset from the top
  166.            Buffer = pointer to mouse pointer image buffer
  167.   Returns: nothing
  168.   Note:    * The pointer image buffer is 64 bytes long.  The first 32
  169.              bytes contain a bit mask which is ANDed with the screen
  170.              image, and the remaining 32 bytes are then XORed with the
  171.              screen image.
  172.     * The hot spot is relative to the upper left corner of the pointer
  173.       image, and each offset must be in the range -16 to 16.  In display
  174.       modes 4 and 5, the horizontal offset must be an even number.
  175. }
  176.  
  177. PROCEDURE SetTextPointer(PtrTyp, AND_Str, XOR_End : word);
  178. { Defines the shape and attributes of the mouse pointer in text modes.
  179.   Call:    PtrTyp  = pointer type
  180.        0 = software cursor
  181.        1 = hardware cursor
  182.     AND_Str = AND mask value (if PtrTyp = 0) or starting line for
  183.        cursor (if PtrTyp = 1)
  184.     XOR_End = XOR mask value (if PtrTyp = 0) or ending line for
  185.        cursor (if PtrTyp = 1)
  186.   Returns: nothing
  187.   Notes:   * If the software text cursor is selected, the masks in
  188.              AND_Str and XOR_End are mapped as follows:
  189.       Bit(s)   Significance
  190.       0-7      character code
  191.       8-10     foreground color
  192.       11       intensity
  193.       12-14    background color
  194.       15       blink
  195.       For Example, the following call would yeild a software cursor
  196.       that inverts the foreground and background colors:
  197.       SetTextPointer(0, $77FF, $7700);
  198.     * When the hardware text cursor is selected, the values in AND_Str
  199.       and XOR_End are the starting and ending lines for the blinking
  200.       cursor generated by the video adapter.  The maximum scan line
  201.       depends on the type of adapter and the current display mode.
  202. }
  203.  
  204. PROCEDURE GetMotionCount(VAR Horiz, Vert : word);
  205. { Returns the net mouse displacement since the last call to this
  206.   procedure.  The returned value is in mickeys; a positive number
  207.   indicates travel to the right or downwards, a negative number
  208.   indicates travel to the left or upwards.  One mickey represents
  209.   approximately 1/200 of an inch of mouse movement.
  210.   Call:    nothing
  211.   Returns: Horiz = horizontal (X) mickey count
  212.     Vert  = vertical (Y) mickey count
  213. }
  214.  
  215. PROCEDURE SetEventHandler(EventMask : word; Handler : pointer);
  216. { Sets the address and event mask for an application program's mouse
  217.   event handler.  The handler is called by the mouse driver whenever
  218.   the specifed mouse events occur.
  219.   Call:    EventMask = event mask
  220.          Bit(s)  Significance(if set)
  221.          0       mouse movement
  222.          1       left button pressed
  223.          2       left button released
  224.          3       right button pressed
  225.          4       right button released
  226.          5       center button pressed
  227.          6       center button released
  228.          7-15    reserved(0)
  229.     Handler   = Pointer to the handler procedure
  230.   Returns: nothing
  231.   Notes:   * The user-defined handler is entered from the mouse driver
  232.              by a far call with the registers set up as follows:
  233.       AX       mouse event flags (see event mask)
  234.       BX       button state
  235.         Bit(s)  Significance(if set)
  236.         0       left button is down
  237.         1       right button is down
  238.         2       center button is down
  239.         3-15    reserved(0)
  240.       CX       horizontal (X) pointer coordinate
  241.       DX       vertical (Y) pointer coordinate
  242.       SI       last raw vertical mickey count
  243.       DI       last raw horizontal mickey count
  244.       DS       mouse driver data segment
  245.     * If an event does not generate a call to the user-defined handler
  246.       because its bit is not set in the event mask, it is still reported
  247.       in the event falgs during calls to the handler for events which
  248.       are enabled.
  249. }
  250.  
  251. PROCEDURE SetLightPen(On_Off : word);
  252. { Turns the light pen emulation by the mouse driver for IBM BASIC on or
  253.   off.  A "pen down" condition is created by pressing the left and right
  254.   mouse buttons simultaneosly.
  255.   Call:    On_Off = true to enable or false to disable emulation.
  256.   Returns: nothing
  257. }
  258.  
  259. PROCEDURE SetPointerExcl(HorMin, VerMin, HorMax, VerMax : word);
  260. { Defines an exclusion area for the mouse pointer.  When the mouse
  261.   pointer lies within the specified area, it is not displayed.
  262.   Call:    HorMin = upper left X coordinate
  263.     VerMin = upper left Y coordinate
  264.     HorMax = lower right X coordinate
  265.     VerMax = lower right Y coordinate
  266.   Returns: nothing
  267.   Note:    *  The exclusion area is replaced by another call to this
  268.        procdure or cancelled by InitMouse and ShowPointer.
  269. }
  270.  
  271. PROCEDURE SwapEventHandlers(VAR Mask : word; VAR Buffer : pointer);
  272. { Set the address and event mask for an application program's mouse
  273.   event handler and returns the address and event mask for the previous
  274.   handler.  The newly installed handler is called by the mouse driver
  275.   whenever the specified mouse events occur.
  276.   Call:    Mask    = event mask
  277.        Bit(s)  Significance(if set)
  278.        0       mouse movement
  279.        1       left button pressed
  280.        2       left button released
  281.        3       right button pressed
  282.        4       right button released
  283.        5       center button pressed
  284.        6       center button released
  285.        7-15    reserved(0)
  286.     Handler = Pointer to the handler procedure
  287.   Returns: Mask    = previous event mask
  288.            Handler = pointer to previous handler
  289.   Notes:   * The notes for SetEventHandler describe the information
  290.              passed to the user-defined event handler.  Also see
  291.              SetAltEventHandler.
  292.     * Calls to the event handler are disabled with InitMouse or by
  293.       setting an event mask of zero.
  294. }
  295.  
  296. FUNCTION GetSaveStateSize : word;
  297. { Returns the size of the buffer required to store the current state of
  298.   the mouse driver.
  299.   Note:    * also see SaveDrvrState and RestoreDrvrState.
  300. }
  301.  
  302. PROCEDURE SaveDrvrState(Buffer : pointer);
  303. { Saves the mouse driver state in a user buffer.  THe minimum size for
  304.   the buffer must be determined by GetSaveStateSize.
  305.   Call:    Buffer = pointer to the user defined buffer.
  306.   Returns: nothing
  307.   Note:    * Use this procedure before executing a child program
  308.              (Exec), in case the child also uses the mouse. After
  309.              the Exec call, restore the previous mouse driver state
  310.              using RestoreDrvrState.
  311. }
  312.  
  313. PROCEDURE RestoreDrvrState(Buffer : pointer);
  314. { Restores the mouse driver state from a user buffer.
  315.   Call:    Buffer = pointer to the user defined buffer.
  316.   Returns: nothing
  317.   Note:    * The mouse driver state must have been previously saved
  318.              into the same buffer with SaveDrvrState.  The format of
  319.              the data in the buffer in undocumented and subject to
  320.              change.
  321. }
  322.  
  323. PROCEDURE SetAltEventHandler(Mask : word; Handler : pointer; VAR Err:
  324. boolean);
  325.  
  326. { Sets the address and event mask for an application program's mouse
  327.   event handler.  As many as three handlers with distinct event masks
  328.   can be registered with this function.  When an event occurs that
  329.   matches one of the masks, the corresponding handler is called by
  330.   the mouse driver.
  331.   Call:    Mask    = event mask
  332.        Bit(s)  Significance(if set)
  333.        0       mouse movement
  334.        1       left button pressed
  335.        2       left button released
  336.        3       right button pressed
  337.        4       right button released
  338.        5       Shift key pressed during button press or release
  339.        6       Ctrl key pressed during button press or release
  340.        7       Alt key pressed during button press or release
  341.        8-15    reserved(0)
  342.     Handler = Pointer to the handler procedure
  343.   Returns: Err     = false if successful, true otherwise
  344.   Notes:   * When this procedure is called, at least one of the bits 5,
  345.              6, and 7 must be set in Mask.
  346.     * The user-defined handler is entered from the mouse driver by a
  347.       far call with the registers set up as follows:
  348.       AX       mouse event flags (see event mask)
  349.       BX       button state
  350.         Bit(s)  Significance(if set)
  351.         0       left button is down
  352.         1       right button is down
  353.         2       center button is down
  354.         3-15    reserved(0)
  355.       CX       horizontal (X) pointer coordinate
  356.       DX       vertical (Y) pointer coordinate
  357.       SI       last raw vertical mickey count
  358.       DI       last raw horizontal mickey count
  359.       DS       mouse driver data segment
  360.     * If an event does not generate a call to the user-defined handler
  361.       because its bit is not set in the event mask, it is still reported
  362.       in the event falgs during calls to the handler for events which
  363.       are enabled.
  364.     * Calls to the handler are disabled with InitMouse.
  365.     * Also see SetEventHandler and SwapEventHandlers.
  366. }
  367.  
  368. PROCEDURE GetAltEventAdrs(VAR Mask : word; VAR Handler : pointer;
  369.      VAR Err : boolean);
  370. { Returns the address for the mouse event handler matching the specified
  371.   event mask.
  372.   Call:    Mask    = event mask
  373.        (see SetAltEventHandler)
  374.   Returns: Mask    = event mask
  375.     Handler = pointer to the alternate event handler
  376.     Err     = false if successful, true if not successful (no handler
  377.        installed or event mask does not match any installed
  378.        handler.
  379.   Note:    * SetAltEventHandler allows as many as three event handler with
  380.       distinct event masks to be installed.  This procedure can be
  381.       called to search for a handler that matches a specific event, so
  382.       that it can be replaced or disabled.
  383. }
  384. PROCEDURE SetMouseSense(Horiz, Vert, Double : word);
  385. { Set the number of mickeys per 8 pixels for horizontal and vertical mouse
  386.   motion and the threshold speed for doubleing pointer motion on the screen.
  387.   One mickey represents approximately 1/200 of an inch of mouse travel.
  388.   Call:    Horiz  = horizontal mickeys (1-32,767; default=8)
  389.     Vert   = vertical mickeys (1-32,767; default=16)
  390.     Double = double speed threshold in mickeys/second (default=64);
  391.   Returns: nothing
  392. }
  393.  
  394. PROCEDURE GetMouseSense(VAR Horiz, Vert, Double : word);
  395. { Return the current mickeys to pixels ratios for vertical and horizontal
  396.   screen movement and the threshold speed for doubling of pointer motion.
  397.   Call:    nothing
  398.   Returns: Horiz  = horizontal mickeys (1-32,767; default=8)
  399.     Vert   = vertical mickeys (1-32,767; default=16)
  400.     Double = double speed threshold in mickeys/second (default=64);
  401. }
  402.  
  403. PROCEDURE SetMouseIntr(Flags : word);
  404. { Sets the rate at which the mouse driver polls the status of the mouse.
  405.   Faster rates provide better resolution in graphics mode but may degrade
  406.   the performance of application programs.
  407.   Call:    Flags = interrupt rate flags
  408.      Bit(s)    Significance(if set)
  409.      0         no interrupts allowed
  410.      1         30 interrupts/second
  411.      2         50 interrupts/second
  412.      3         100 interrupts/second
  413.      4         200 interrupts/second
  414.      5-15      reserved(0)
  415.   Returns: nothing
  416.   Notes:   * This procedure is applicable for the InPort Mouse only.
  417.     * In more than one bit is set in Flags, the lowest order bit
  418.       prevails.
  419. }
  420.  
  421. PROCEDURE SetPointerPage(Page : word);
  422. { Selects the display page for the mouse pointer.
  423.   Call:    Page = display page
  424.   Returns: nothing
  425.   Note:    * The valid page numbers depend on the current display mode.
  426. }
  427.  
  428. FUNCTION GetPointerPage : word;
  429. { Returns the current display page for the mouse pointer.
  430. }
  431.  
  432. PROCEDURE DisableMouseDrvr(VAR Handler : pointer; VAR Err : boolean);
  433. { Disables the mouse driver and returns the address of the previous Int 33H
  434.   handler.
  435.   Call:    nothing
  436.   Returns: Handler = pointer to previous Int 33H handler
  437.     Err     = false if successful, true otherwise
  438.   Notes:   * When this procedure is called, the mouse driver releases any
  439.       interrupt vectors it hase captured OTHER than Int 33H (which may
  440.       be Int 10H, Int 71H, and/or Int 74H).  The application program
  441.       can COMPLETE the process of logically removing the mouse driver
  442.       by restoring the original contents of the Int 33H vector with
  443.       SetIntVec using the pointer returned by the procedure.
  444.     * Also see EnableMouseDrvr.
  445. }
  446.  
  447. PROCEDURE EnableMouseDrvr;
  448. { Enables the mouse driver and the servicing fo mouse interrupts.
  449.   Call:    nothing
  450.   Returns: nothing
  451.   Note:    * Also see DisableMouseDrvr
  452. }
  453.  
  454. PROCEDURE ResetMouseDrvr(VAR Buttons : word; VAR Err : boolean);
  455. { Resets the mouse driver and returns driver status.  If the mouse pointer was
  456.   previously visible, is is removed trom the screen, and any presoiusly
  457.   installed user event handlers for mouse events are disabled.
  458.   Call:    nothing
  459.   Returns: Buttons = number of mouse buttons
  460.     Err     = false if mouse support is available, true otherwise
  461.   Note:    * This procedure differ from InitMouse in that there is no
  462.       initialization of the mouse hardware.
  463. }
  464.  
  465. PROCEDURE SetMouseLang(LangNumber : word);
  466. { Selects the language that will be used by the mouse driver for prompts and
  467.   error messages.
  468.   Call:    LangNumber = language number
  469.    0 = English
  470.    1 = French
  471.    2 = Dutch
  472.    3 = German
  473.    4 = Swedish
  474.    5 = Finnish
  475.    6 = Spanish
  476.    7 = Portuguese
  477.    8 = Italian
  478.   Returns: nothing
  479.   Note:    * This procedure is only functional in international versions of
  480.       the Microsoft Mouse drive.
  481. }
  482.  
  483. FUNCTION GetMouseLang : word;
  484. { Returns the number of the language that is used by the mouse driver for
  485.   prompts and error messages.
  486.   Call:    nothing
  487.   Returns: language number (see above)
  488.   Note:    * This procedure is only functional in international versions of
  489.       the Microsoft Mouse drive.
  490. }
  491.  
  492. PROCEDURE GetMouseInfo(VAR MajVer, MinVer, MouseType, IRQ : word);
  493. { Returns the mouse driver version number, mouse type, and the IRQ number of
  494.   the interrupt used by the mouse adapter.
  495.   Call:    nothing
  496.   Returns: MajVer    = major version number (6 for version 6.10, etc.)
  497.     MinVer    = minor version number (10 for version 6.10, etc.)
  498.     MouseType = mouse type
  499.          1 = bus mouse
  500.          2 = serial mouse
  501.          3 = InPort mouse
  502.          4 = PS/2 mouse
  503.          5 = HP mouse
  504.     IRQ       = IRQ number
  505.          0                = PS/2
  506.          2, 3, 4, 5, or 7 = IRQ number
  507. }
  508.  
  509.  
  510. IMPLEMENTATION
  511.  
  512. CONST
  513.   MouseInt = $33;
  514.  
  515. VAR
  516.   Reg : Registers;
  517.  
  518.  
  519. PROCEDURE InitMouse(VAR Buttons : word; VAR Err : boolean);
  520. { Iniialize the mouse driver, if present, and return the number of
  521. buttons. }
  522.  
  523. BEGIN
  524.   Reg.AX := 0;
  525.   intr(MouseInt, Reg);
  526.   Buttons := Reg.BX;
  527.   IF (Reg.AX = 0) THEN
  528.     Err := true
  529.   ELSE
  530.     Err := false;
  531. END;
  532.  
  533.  
  534. PROCEDURE ShowPointer;
  535.  
  536. BEGIN
  537.   Reg.AX := 1;
  538.   intr(MouseInt, Reg);
  539. END;
  540.  
  541. PROCEDURE HidePointer;
  542.  
  543. BEGIN
  544.   Reg.AX := 2;
  545.   intr(MouseInt, Reg);
  546. END;
  547.  
  548. FUNCTION ButtonPressed(Mask : word) : boolean;
  549.  
  550. BEGIN
  551.   Reg.AX := 3;
  552.   intr(MouseInt, Reg);
  553.   IF (Reg.BX > 0) THEN
  554.     ButtonPressed := true
  555.   ELSE
  556.     ButtonPressed := false;
  557. END;
  558.  
  559. PROCEDURE GetMousePosition(VAR Buttons, Horiz, Vert : word);
  560.  
  561. BEGIN
  562.   Reg.AX := 3;
  563.   intr(MouseInt, Reg);
  564.   Buttons := Reg.BX;
  565.   Horiz := Reg.CX;
  566.   Vert := Reg.DX;
  567. END;
  568.  
  569. FUNCTION MouseIn(x1,y1,x2,y2: word):boolean;
  570. VAR b,x,y: word;
  571. BEGIN
  572.   GetMousePosition(b,x,y);
  573.   MouseIn:=(x>=x1) AND (x<=x2) AND (y>=y1) AND (y<=y2)
  574. END;
  575.  
  576. PROCEDURE SetPointerPosition(Horiz, Vert : word);
  577.  
  578. BEGIN
  579.   Reg.AX := 4;
  580.   Reg.CX := Horiz;
  581.   Reg.DX := Vert;
  582.   intr(MouseInt, Reg);
  583. END;
  584.  
  585. PROCEDURE GetPressInfo(Button : word;
  586.          VAR Stat, Count, Horiz, Vert : word);
  587.  
  588. BEGIN
  589.   Reg.AX := 5;
  590.   Reg.BX := Button;
  591.   intr(MouseInt, Reg);
  592.   Stat := Reg.AX;
  593.   Count := Reg.BX;
  594.   Horiz := Reg.CX;
  595.   Vert := Reg.DX;
  596. END;
  597.  
  598.  
  599. PROCEDURE GetReleaseInfo(Button : word;
  600.     VAR Stat, Count, Horiz, Vert : word);
  601.  
  602. BEGIN
  603.   Reg.AX := 6;
  604.   Reg.BX := Button;
  605.   intr(MouseInt, Reg);
  606.   Stat := Reg.AX;
  607.   Count := Reg.BX;
  608.   Horiz := Reg.CX;
  609.   Vert := Reg.DX;
  610. END;
  611.  
  612. PROCEDURE SetLimits(HorMin, HorMax, VerMin, VerMax : word);
  613.  
  614. BEGIN
  615.   IF (HorMin > 0) AND (HorMax > 0) THEN
  616.     BEGIN
  617.       Reg.AX := 7;
  618.       Reg.CX := HorMin;
  619.       Reg.DX := HorMax;
  620.       intr(MouseInt, Reg);
  621.     END;
  622.   IF (VerMin > 0) AND (VerMax > 0) THEN
  623.     BEGIN
  624.       Reg.AX := 8;
  625.       Reg.CX := VerMin;
  626.       Reg.DX := VerMax;
  627.       intr(MouseInt, Reg);
  628.     END;
  629. END;
  630.  
  631. PROCEDURE SetPointerShape(Horiz, Vert : word; Buffer : pointer);
  632.  
  633. BEGIN
  634.   Reg.AX := 9;
  635.   Reg.BX := Horiz;
  636.   Reg.CX := Vert;
  637.   Reg.ES := Seg(Buffer);
  638.   Reg.DX := Ofs(Buffer);
  639.   intr(MouseInt, Reg);
  640. END;
  641.  
  642. PROCEDURE SetTextPointer(PtrTyp, AND_Str, XOR_End : word);
  643.  
  644. BEGIN
  645.   Reg.AX := 10;
  646.   Reg.BX := PtrTyp;
  647.   Reg.CX := AND_Str;
  648.   Reg.DX := XOR_End;
  649.   intr(MouseInt, Reg);
  650. END;
  651.  
  652. PROCEDURE GetMotionCount(VAR Horiz, Vert : word);
  653.  
  654. BEGIN
  655.   Reg.AX := 11;
  656.   intr(MouseInt, Reg);
  657.   Horiz := Reg.CX;
  658.   Vert := Reg.DX;
  659. END;
  660.  
  661. PROCEDURE SetEventHandler(EventMask : word; Handler : pointer);
  662.  
  663. BEGIN
  664.   Reg.AX := 12;
  665.   Reg.CX := EventMask;
  666.   Reg.ES := seg(Handler);
  667.   Reg.DX := ofs(Handler);
  668.   intr(MouseInt, Reg);
  669. END;
  670.  
  671. PROCEDURE SetLightPen(On_Off : word);
  672.  
  673. BEGIN
  674.   IF (On_Off = 0) THEN
  675.     Reg.AX := 14
  676.   ELSE
  677.     Reg.AX := 13;
  678.   intr(MouseInt, Reg);
  679. END;
  680.  
  681. PROCEDURE SetPointerExcl(HorMin, VerMin, HorMax, VerMax : word);
  682.  
  683. BEGIN
  684.   Reg.AX := 16;
  685.   Reg.CX := HorMin;
  686.   Reg.SI := HorMax;
  687.   Reg.DX := VerMin;
  688.   Reg.DI := VerMax;
  689.   intr(MouseInt, Reg);
  690. END;
  691.  
  692. PROCEDURE SwapEventHandlers(VAR Mask : word; VAR Buffer : pointer);
  693.  
  694. BEGIN
  695.   Reg.AX := 20;
  696.   Reg.CX := Mask;
  697.   Reg.ES := Seg(Buffer);
  698.   Reg.DX := Ofs(Buffer);
  699.   intr(MouseInt, Reg);
  700.   Mask := Reg.CX;
  701.   Buffer := Ptr(Reg.ES, Reg.DX);
  702. END;
  703.  
  704. FUNCTION GetSaveStateSize : word;
  705.  
  706. BEGIN
  707.   Reg.AX := 21;
  708.   intr(MouseInt, Reg);
  709.   GetSaveStateSize := Reg.BX;
  710. END;
  711.  
  712. PROCEDURE SaveDrvrState(Buffer : pointer);
  713.  
  714. BEGIN
  715.   Reg.AX := 22;
  716.   Reg.ES := Seg(Buffer);
  717.   Reg.DX := Ofs(Buffer);
  718.   intr(MouseInt, Reg);
  719. END;
  720.  
  721. PROCEDURE RestoreDrvrState(Buffer : pointer);
  722.  
  723. BEGIN
  724.   Reg.AX := 23;
  725.   Reg.ES := Seg(Buffer);
  726.   Reg.DX := Ofs(Buffer);
  727.   intr(MouseInt, Reg);
  728. END;
  729.  
  730. PROCEDURE SetAltEventHandler(Mask : word; Handler : pointer; VAR Err:
  731. boolean);
  732.  
  733. BEGIN
  734.   Reg.AX := 24;
  735.   Reg.CX := Mask;
  736.   Reg.ES := Seg(Handler);
  737.   Reg.DX := Ofs(Handler);
  738.   intr(MouseInt, Reg);
  739.   IF (Reg.AX = 24) THEN
  740.     Err := false
  741.   ELSE
  742.     Err := true;
  743. END;
  744.  
  745. PROCEDURE GetAltEventAdrs(VAR Mask : word; VAR Handler : pointer;
  746.      VAR Err : boolean);
  747.  
  748. BEGIN
  749.   Reg.AX := 25;
  750.   Reg.CX := Mask;
  751.   intr(MouseInt, Reg);
  752.   IF (Reg.CX > 0) THEN
  753.     BEGIN
  754.       Mask := Reg.CX;
  755.       Handler := Ptr(Reg.ES, Reg.DX);
  756.       Err := false;
  757.     END
  758.   ELSE
  759.     Err := true;
  760. END;
  761.  
  762. PROCEDURE SetMouseSense(Horiz, Vert, Double : word);
  763.  
  764. BEGIN
  765.   Reg.AX := 26;
  766.   Reg.BX := Horiz;
  767.   Reg.CX := Vert;
  768.   Reg.DX := Double;
  769.   intr(MouseInt, Reg);
  770. END;
  771.  
  772. PROCEDURE GetMouseSense(VAR Horiz, Vert, Double : word);
  773.  
  774. BEGIN
  775.   Reg.AX := 27;
  776.   intr(MouseInt, Reg);
  777.   Horiz := Reg.BX;
  778.   Vert := Reg.CX;
  779.   Double := Reg.DX;
  780. END;
  781.  
  782. PROCEDURE SetMouseIntr(Flags : word);
  783.  
  784. BEGIN
  785.   Reg.AX := 28;
  786.   Reg.BX := Flags;
  787.   intr(MouseInt, Reg);
  788. END;
  789.  
  790. PROCEDURE SetPointerPage(Page : word);
  791.  
  792. BEGIN
  793.   Reg.AX := 29;
  794.   Reg.BX := Page;
  795.   intr(MouseInt, Reg);
  796. END;
  797.  
  798.  
  799. FUNCTION GetPointerPage : word;
  800.  
  801. BEGIN
  802.   Reg.AX := 30;
  803.   intr(MouseInt, Reg);
  804.   GetPointerPage := Reg.BX;
  805. END;
  806.  
  807. PROCEDURE DisableMouseDrvr(VAR Handler : pointer; VAR Err : boolean);
  808.  
  809. BEGIN
  810.   Reg.AX := 31;
  811.   intr(MouseInt, Reg);
  812.   IF (Reg.AX = 31) THEN
  813.     BEGIN
  814.       Handler := ptr(Reg.ES, Reg.DX);
  815.       Err := false;
  816.     END
  817.   ELSE
  818.     Err := true;
  819. END;
  820.  
  821. PROCEDURE EnableMouseDrvr;
  822.  
  823. BEGIN
  824.   Reg.AX := 32;
  825.   intr(MouseInt, Reg);
  826. END;
  827.  
  828. PROCEDURE ResetMouseDrvr(VAR Buttons : word; VAR Err : boolean);
  829.  
  830. BEGIN
  831.   Reg.AX := 33;
  832.   intr(MouseInt, Reg);
  833.   IF (Reg.AX = $FFFF) THEN
  834.     BEGIN
  835.       Buttons := Reg.BX;
  836.       Err := false;
  837.     END
  838.   ELSE
  839.     Err := true;
  840. END;
  841.  
  842. PROCEDURE SetMouseLang(LangNumber : word);
  843.  
  844. BEGIN
  845.   Reg.AX := 34;
  846.   Reg.BX := LangNumber;
  847.   intr(MouseInt, Reg);
  848. END;
  849.  
  850. FUNCTION GetMouseLang : word;
  851.  
  852. BEGIN
  853.   Reg.AX := 35;
  854.   intr(MouseInt, Reg);
  855.   GetMouseLang := Reg.BX;
  856. END;
  857.  
  858. PROCEDURE GetMouseInfo(VAR MajVer, MinVer, MouseType, IRQ : word);
  859.  
  860. BEGIN
  861.   Reg.AX := 36;
  862.   intr(MouseInt, Reg);
  863.   MajVer := Reg.BH;
  864.   MinVer := Reg.BL;
  865.   MouseType := Reg.CH;
  866.   IRQ := Reg.CL;
  867. END;
  868.  
  869. END.
  870.